#!/bin/sh
# PCP QA Test No. 1552
# simple mmv PMDA on-disk check
#
# Copyright (c) 2025 Ken McDonell.  All Rights Reserved.
#

if [ $# -eq 0 ]
then
    seq=`basename $0`
    echo "QA output created by $seq"
else
    # use $seq from caller, unless not set
    [ -n "$seq" ] || seq=`basename $0`
    echo "QA output created by `basename $0` $*"
fi

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

pmda=${PCP_PMDAS_DIR}/mmv/pmda_mmv,mmv_init

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=0	# success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e "s@$tmp@TMP@g" \
	-e 's/\[[A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]]/[DATESTAMP]/' \
	-e 's/pminfo([0-9][0-9]*)/pminfo(PID)/' \
    # end
}

# real QA test starts here
export PCP_TMP_DIR=$tmp
mkdir -p $PCP_TMP_DIR/mmv || exit 1
src/mmv_ondisk

pminfo -L -Kclear -Kadd,70,$pmda -Dappl0 -mdtTf mmv.ondisk 2>&1 \
| _filter

$PCP_PMDAS_DIR/mmv/mmvdump $PCP_TMP_DIR/mmv/ondisk 2>&1 \
| _filter

# success, all done
exit
